import requests

from app import BASE_URL, HEADERS


class LoginAPI(object):
    """
    登录接口封装
    """

    def __init__(self):
        self.login_url = BASE_URL + "/api/sys/login"

    # 登录(用于parameterized传参使用)
    def login(self, mobile, password):
        data = {"mobile": mobile, "password": password}
        response = requests.post(self.login_url, headers=HEADERS, json=data)
        return response

    # 有参数测试使用登录
    def login_params(self, data):
        return requests.post(self.login_url, headers=HEADERS, json=data)

    # 空参数测试使用登录
    # def login_params_empty(self):
    #     return requests.post(self.login_url, headers=HEADERS)


if __name__ == '__main__':
    lg = LoginAPI()
    print(lg.login("13800000002", "123456").json())
